part of 'widget.dart';

class _LexicalItemImageViewerView extends StatelessWidget {
  const _LexicalItemImageViewerView({
    required this.imagePath,
    required this.onImageDeletionButtonPressed,
    this.width,
  });

  final String imagePath;
  final VoidCallback onImageDeletionButtonPressed;
  final double? width;

  Widget _buildImageDeletionButton({
    required BuildContext context,
  }) {
    return AppButton(
      onPressed: onImageDeletionButtonPressed,
      child: SizedBox(
        width: 38,
        height: 38,
        child: Center(
          child: DecoratedIcon(
            icon: Icon(
              CupertinoIcons.xmark,
              color: _LexicalItemImageViewerTheme.of(context).iconColor,
              size: 27.1,
            ),
            decoration: IconDecoration(
              border: IconBorder(
                width: 1.7,
                color: _LexicalItemImageViewerTheme.of(context).iconOutlineColor,
              ),
            ),
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: width,
      child: AspectRatio(
        aspectRatio: 600 / 432,
        child: Stack(
          children: [
            Image.file(
              File(imagePath),
              fit: BoxFit.contain,
              filterQuality: FilterQuality.medium,
            ),
            Positioned.fill(
              child: Align(
                alignment: Alignment.topRight,
                child: _buildImageDeletionButton(
                  context: context,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
